import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.filechooser.FileNameExtensionFilter;


public class Jframe {
	public static void main(String[] args) throws IOException {
		  Toolkit toolkit = Toolkit.getDefaultToolkit();
		  final JFrame frame = new JFrame();
		  frame.setSize(600, 400);
		  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		  frame.setResizable(false);
		  final Dimension scrnsize = toolkit.getScreenSize();
		  final JFileChooser fc = new JFileChooser();
		  frame.setBounds((int) ((float) .3 * scrnsize.width),
		    (int) ((float) 0.3 * scrnsize.height), 550, 450);
		  frame.setLayout(null);
		  JButton nieuwButton, openButton;
		  JMenuBar bar = new JMenuBar();

		  // File Menu, F - Mnemonic
		  JMenu fileMenu = new JMenu("File");
		  fileMenu.setMnemonic(KeyEvent.VK_F);

		  JMenuItem exit = new JMenuItem("Exit");
		  exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
		    ActionEvent.ALT_MASK));
		  // exit.setBounds(2, 10, 40, 20);
		  exit.addActionListener(new ActionListener() {
		   public void actionPerformed(ActionEvent e) {

		    System.exit(0);
		   }
		  });
		  fileMenu.add(exit);
		  bar.add(fileMenu);

		  // Edit Menu, E - Mnemonic

		  // Move help menu to right side
		  bar.add(Box.createHorizontalGlue());

		  // Help Menu, H - Mnemonic
		  JMenu helpMenu = new JMenu("Help");
		  JMenuItem about = new JMenuItem("About");
		  about.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,
		    ActionEvent.ALT_MASK));

		  about.addActionListener(new ActionListener() {
		   public void actionPerformed(ActionEvent e) {

		    JOptionPane.showMessageDialog(frame, "This is the about Menu");
		   }
		  });
		  helpMenu.add(about);
		  helpMenu.setMnemonic(KeyEvent.VK_H);

		  bar.add(helpMenu);
		  frame.setJMenuBar(bar);

		  final JMenuBar finalbar = bar;

		  // single.getContentPane().setBackground(kleur.brighter());

		  frame.setVisible(true);
		  //set filter for xls only
		  FileNameExtensionFilter filter = new FileNameExtensionFilter(
	                ".XLS Files", "xls");
	       fc.setFileFilter(filter);
	 
		  JLabel welcome = new JLabel(
		    "Welkom");
		  welcome.setFont(new Font("Serif", Font.BOLD, 20));
		  welcome.setBounds(10, 40, 600, 50);
		  frame.add(welcome);

		  JLabel kiesdan = new JLabel("Openen of nieuw?");
		  kiesdan.setFont(new Font("Serif", Font.BOLD, 14));
		  kiesdan.setBounds(150, 100, 600, 50);
		  frame.add(kiesdan);
		  openButton = new JButton("Open a File...");
	        openButton.addActionListener(new ActionListener() {
	 		   public void actionPerformed(ActionEvent e) {
	 			  int returnVal = fc.showOpenDialog(frame);
	 			 
	 	            if (returnVal == JFileChooser.APPROVE_OPTION) {
	 	                File file = fc.getSelectedFile();
	 	                //This is where a real application would open the file.
	 	             
	 	            }
	 		   }
	        }
	        );
	     
	        //Create the save button.  We use the image from the JLF
	        //Graphics Repository (but we extracted it from the jar).
	        nieuwButton = new JButton("Start nieuwe Klassificatie");
	        nieuwButton.addActionListener(new ActionListener() {
		 		   public void actionPerformed(ActionEvent e) {
		 			  int returnVal = fc.showSaveDialog(frame);
		 	            if (returnVal == JFileChooser.APPROVE_OPTION) {
		 	                File file = fc.getSelectedFile();
		 	               
		 	               
		 	            } else {
		 	               
		 	            }
		        }
	        }
		        );
	 
	        nieuwButton.setBounds(50, 300, 200, 40);
	        openButton.setBounds(300, 300, 200, 40);
	        frame.add(nieuwButton);
	        frame.add(openButton);

		  
		  
	      
	}
	public static void closeFrame(JFrame frame) {
		  frame.dispose();
		  frame.setVisible(false);
		 }
}
